package org.yx.controller;

import java.io.File;

import io.jboot.web.controller.JbootController;
import io.jboot.web.controller.annotation.RequestMapping;

import com.jfinal.core.JFinal;
import com.xiaoleilu.hutool.io.FileUtil;

@RequestMapping("/export")
public class DownloadController extends JbootController {
	public void index() {
		String fileName = getPara("fileName");

		String filePath = JFinal.me().getConstants().getBaseDownloadPath() + "/export/" + fileName;

		File destFile = FileUtil.file(filePath);
		if (destFile == null || !destFile.exists()) {
			renderText("Can not find file(找不到指定文件）.");
			return;
		}
		renderFile(destFile);

		System.out.println(destFile.getAbsolutePath());
		//FileUtil.del(destFile);
	}
}
